home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 34.zip / BS1 part 34 / megadisc PD 14.adf / PROGRAMS / AREXX / Apropos.rexx < prev    next >
OS/2 REXX Batch file  |  1989-12-11  |  2KB  |  57 lines

  1.  
  2.     /* UNIX-like `apropos' command to search for documentation */
  3.  
  4. arg arg1 arg2 arg3 arg4     /* parse the command line arguments */
  5.  
  6. if arg1 = '-D' then ; do    /* we have been given a doc path    */
  7.     if arg4 ~= '' then ; do
  8.         say 'apropos: too many arguments'
  9.         exit 5
  10.         end
  11.     if arg2 = '' then ; do
  12.         say 'apropos: missing documentation path'
  13.         exit 5
  14.         end
  15.     if arg3 = '' then ; do
  16.         say 'apropos: missing search key'
  17.         exit 5
  18.         end
  19.     rt = right( arg2, 1 )           /* Get the doc path into the form   */
  20.     if rt ~= ':' & rt ~= '/' then   /* we want; pathname followed by    */
  21.         docpath = arg2'/'           /* either a ':' or a '/', as        */
  22.     else                            /* appropriate.                     */
  23.         docpath = arg2
  24.     searchkey = arg3
  25.     end
  26. else ; do                        /* we should only have a keyword   */
  27.     if arg2 ~= '' then ; do
  28.         say 'apropos: too many arguments'
  29.         exit 5
  30.         end
  31.     if arg1 = '' then ; do
  32.         say 'Usage: apropos [-d <DocPath>] <SearchKey>'
  33.         exit 0
  34.         end
  35.     docpath = 'DOC:'
  36.     searchkey = arg1
  37.     end
  38.  
  39. if exists( docpath'doc.index' ) then ; do
  40.     address command
  41.     tempfile = 'T:'searchkey'_apropos.tmp'
  42.     'search >'tempfile docpath'doc.index' ' 'searchkey' ' nonum
  43.     parse value statef( tempfile ) with . len . /* find length of output */
  44.     if len = 0 then     /* no output was generated */
  45.         say 'Nothing appropriate ...'
  46.     else
  47.         'type' tempfile /* display all the matches  */
  48.     'delete' tempfile
  49.     exit 0
  50.     end
  51. else ; do
  52.     say 'apropos: could not find index file'
  53.     exit 10
  54.     end
  55.  
  56.  
  57.